import unittest
import ddt
import time
from selenium.webdriver.support.ui import Select
from Base.BaseSetings import *
from Business.Student_Management_PZY import woniuboss
from WoniuBossPOM import Student_Management_POM_PZY
# from WoniuBossPOM.Student_Management_POM_PZY import Stu_Sys_Mamagement
# from WoniuBossPOM.All_Management_POM import All_Mamagement


@ddt.ddt
class Us(unittest.TestCase):
    def setUp(self) -> None:
        self.dr = woniuboss()

    # def tearDown(self) -> None:
    #     self.dr.closeBroswer()

    # @ddt.file_data(TestData_dir + "students.yaml")
    # def test_stu(self,**kwargs):  # 学员信息
    #     result = self.dr.test_stu(kwargs.get('stu_name'))
    #     self.assertEqual(result,kwargs.get('assert_info'))

    # @ddt.file_data(TestData_dir + "alter_stu.yaml")
    # def test_alter(self,**kwargs):  # 修改操作
    #     self.dr.get_home_student_obj().click()
    #     self.dr.get_home_stu_info_obj().click()
    #     time.sleep(2)
    #     self.dr.get_home_decode_obj().click()  # 解密
    #     time.sleep(2)
    #     self.dr.get_home_decode1_obj().send_keys(kwargs.get('password'))
    #     time.sleep(2)
    #     self.dr.get_home_access_obj().click()
    #     time.sleep(2)
    #     self.dr.get_home_alter_obj().click()  # [修改]按钮
    #     time.sleep(2)
    #     ele_select5 = self.dr.get_home_edu_obj()  # [学历]下拉框
    #     Select(ele_select5).select_by_index(1)
    #     time.sleep(2)
    #     self.dr.get_home_save_obj().click()  # [保存]按钮
    #     time.sleep(2)
    #     self.dr.get_home_access1_obj().click()  # [确认]按钮
    #     result4 = self.dr.get_role_data().text
    #     self.assertEqual(result4,'本科')

    @ddt.file_data(TestData_dir + "search_user.yaml")
    def test_search_user(self,**kwargs):  # 用户管理  用户查询
        result =self.dr.search_user()
        print(result)
        self.assertEqual(result, kwargs.get('assert_info'))
    #
    # def test_roleadd(self):  # 给用户增加角色
    #     time.sleep(2)
    #     self.dr.get_home_system_obj().click()
    #     self.dr.get_home_system_user_obj().click()
    #     time.sleep(2)
    #     self.dr.get_home_role_obj().click()
    #     self.dr.get_home_addrole_obj().click()
    #     self.dr.get_home_access2_obj().click()
    #     time.sleep(2)
    #     self.dr.get_home_access3_obj().click()
    #     time.sleep(2)
    #     self.dr.get_home_closedoc_obj().click()

    def test_alterrole(self):  # 修改用户描述
        result = self.dr.alterrole()
        print(result)
        self.assertEqual(result,'我是班主任')

    # def test_alterpwd(self):  # 重置密码
    #     self.dr.get_home_system_obj().click()
    #     self.dr.get_home_system_user_obj().click()
    #     self.dr.get_home_search1_obj().click()
    #     self.dr.get_home_alterpwd_obj().click()
    #     self.dr.get_home_pwd_obj().clear()
    #     self.dr.get_home_pwd_obj().send_keys('woniu123')
    #     time.sleep(2)
    #     self.dr.get_home_savepwd_obj().click()
    #     time.sleep(2)
    #     self.dr.get_home_access4_obj().click()
    #     time.sleep(2)
    #     self.dr.get_home_closedoc_obj().click()
    #
    # def test_role_management(self):  # 角色管理   新增角色
    #     time.sleep(2)
    #     self.dr.get_home_system_obj().click()
    #     self.dr.get_home_role1_obj().click()
    #     self.dr.get_home_roleadd_obj().click()
    #     self.dr.get_home_role_name_obj().click()
    #     self.dr.get_home_role_name_obj().send_keys('老板')
    #     self.dr.get_home_save_role_obj().click()
    #     self.dr.get_home_access6_obj().click()
    #
    # def test_search_role(self):  # 查询新增角色
    #     self.dr.get_home_system_obj().click()
    #     self.dr.get_home_role1_obj().click()
    #     time.sleep(2)
    #     self.dr.get_home_rolesearch_obj().send_keys('老板')
    #     self.dr.get_search().click()  # 查询按钮
    #     result3 = self.dr.get_newrole().text
    #     self.assertEqual(result3,'老板')
    #
    # def test_alter_role(self):  # 修改角色-删除
    #     self.dr.get_home_system_obj().click()
    #     self.dr.get_home_role1_obj().click()
    #     time.sleep(2)
    #     self.dr.get_home_rolesearch_obj().send_keys('老板')
    #     self.dr.get_search().click()  # 查询按钮
    #     time.sleep(2)
    #     self.dr.get_home_alter_role_obj().click()
    #     self.dr.get_home_role_name_obj().clear()  # 清空角色框
    #     self.dr.get_home_role_alter_obj().click()  # 点击保存按钮
    #     self.dr.get_home_access6_obj().click()  # 确认键跟新增后的确认键为同一个

    # def test_closeBrower(self):  # 关闭网页
    #     self.dr.get_home_close_obj()


if __name__ == '__main__':
    unittest.main()